/**********************************************
 *  filename : ft_kernel_conntrack_proto_tcp.c
 **********************************************/


////////////////////////////////////////////////
// define & initialize the struct

struct ft_conntrack_proto ft_ct_proto_tcp = 
{
	.proto_num	= IPPROTO_TCP,
	.name		= "tcp",
	
	.get_tuple	= get_tuple,
	.ivt_tuple	= ivt_tuple,
	.create		= create,
	.packet		= packet,
	.error		= error,
};

///////////////////////////////////////////////
// functions

static bool get_tuple(const struct sk_buff *skb, const struct ft_conntrack_tuple *ptuple)
{
	const struct tcphdr *th;
	struct tcphadr		_th;

	th = skb_header_pointer(skb, skb_transport_offset(skb), sizeof(_th), &_th);
	if (th == NULL) return false;

	ptuple->src.proto.tcp.port = th->source;
	ptuple->dst.proto.tcp.port = th->dest;

	return true;
}

static bool ivt_tuple(const struct ft_conntrack_tuple *po, const struct ft_conntrack_tuple *pr)
{
	pr->src.proto.tcp.port = po->dst.proto.tcp.port;
	pr->dst.proto.tcp.port = po->src.proto.tcp.port;

	return true;
}

static bool create(struct ft_conntrack *ct, const struct sk_buff *skb, unsigned int data_off)
{
	return true;
}

static int  packet(struct ft_conntrack *ct, const struct sk_buff *skb, unsigned int data_off)
{
	return NF_ACCEPT;
}

static bool error()
{
}
